<template>
  <div>
    <a-modal
      :title="title"
      :visible="visible"
      @ok="handleOk"
      @cancel="handleCancel"
      :width="500"
      :maskClosable="false"
      :destroyOnClose="true"
      :keyboard="false"
    >
  <div>
    <a-radio-group v-model.number="formData.reason">
      <div><a-radio value="没有货了">没有货了</a-radio></div>
      <div>
        <a-radio value="供应商不再合作">供应商不再合作</a-radio>
      </div>
      <div>
        <a-radio value="用户下错单">用户下错单</a-radio>
      </div>
      <div>
        <a-radio value="购买价格问题">购买价格问题</a-radio>
      </div>
      <div>
        <a-radio value="其它">其它</a-radio>
      </div>
    </a-radio-group>
    <br>
    具体原因:
    <br>
    <a-textarea style="width: 350px;margin-left: 40px;" v-model="formData.reasonDesc"  :disabled="formData.reason!=='其它'">

    </a-textarea>
  </div>
   </a-modal>
  </div>
</template>

<script>
  export default {
    name: "withdrawMoney",
    props:{
      title:{
        type:String,
        default:'发起退款原因'
      },
      visible:{
        type:Boolean,
        default:false
      },
      records: {
        type: Object,
        default() {
          return {};
        },
      },
    },

    watch:{
      visible:{
        handler(newValue,oldValue){
          console.log(newValue)
          console.log(this.records)
          this.formData.id = this.records.id
        }
      }
    },
    data(){
      return{
        formData:{
          // 这个id 是订单id
          id:'',
          // 原因类型
          reason:"",
          // 具体原因
          reasonDesc:''
        }
      }
    },
    methods:{
      handleOk(){
        // 表单验证后把数据发给父组件
        if (this.formData.reason ===5 && this.formData.reasonDesc === ""){
          return this.$message.error("其它原因不能为空")
        }
        this.$emit("handleSubmit",this.formData)
      },

      handleCancel(){
        this.formData.reasonDesc = ""
        this.$emit("handleCancel",false)
      }
    }
  }
</script>

<style scoped>

</style>